package net.cheyo.weibo;

import org.apache.log4j.Logger;

import weibo4j.Oauth;
import weibo4j.model.WeiboException;

import com.opensymphony.xwork2.ActionSupport;

public class WeiboLoginCallbackAction extends ActionSupport
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private String code;

    public static Logger logger = Logger
            .getLogger(WeiboLoginCallbackAction.class);

    public String execute()
    {
        if (null == code)
        {
            return "error";
        }

        logger.info("code :" + code);

        Oauth oauth = new Oauth();
        try
        {
            logger.info("AccessToken: " + oauth.getAccessTokenByCode(code));
        }
        catch (WeiboException e)
        {
            logger.error(e);
        }

        return "success";
    }

    public String getCode()
    {
        return code;
    }

    public void setCode(String code)
    {
        this.code = code;
    }

}
